home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / info-service / gopher / incoming / gopher.query.readme < prev    next >
Encoding:
Text File  |  1992-07-19  |  4.2 KB  |  171 lines

  1.  
  2.  
  3. The gopher.query.patch is patch for the Unix gopher client, and gopher server
  4. version 1.01, to add the 'q' type. 
  5.  
  6. You need strtok for the client. If you don't have it, a copy 
  7. (from ftp.uu.net:packages/bsd-sources/lib/libc/string/).
  8. provided at the end of this file.
  9.  
  10. To set up a query type, create your favorite .Link type file like so:
  11.  
  12. Name=Finger @Stanford.EDU
  13. Type=q
  14. ReturnType=0
  15. Prompt=Enter finger query
  16. Port=79
  17. Path=
  18. Host=stanford.edu
  19.  
  20.  
  21. If you don't want to/can't modifiy the gopherd, you can create a Link that
  22. looks like the following instead:
  23.  
  24. Name=Finger @Stanford.EDU
  25. Type=q
  26. Port=79
  27. Path=0|1|Enter finger query
  28. Host=stanford.edu
  29.  
  30. Notes:
  31.   
  32.       The formating is scrict. If you are using Type=q then you must
  33.       have ReturnType= and at least 1 Prompt= specified.
  34.  
  35. You can have multiple prompts like so:
  36.  
  37. Name=Query Example
  38. Type=q
  39. ReturnType=0
  40. Prompt=Value 1
  41. Prompt=Value 2
  42. Prompt=Value 3
  43. Prompt=Value 4
  44. Port=4325
  45. Path=example
  46. Host=slapshot.stanford.edu
  47.  
  48. In fact, give that link a try. The following perl script is sitting on that
  49. port:
  50.  
  51. #!/usr/local/bin/perl
  52.  
  53. #$|=1;
  54. ($<,$>) = (-2,-2) unless $>;
  55. $_ = <STDIN>; s/\r//; s/\n//;
  56. print "\n";
  57. print "I was passed the following: $_\n";
  58. print "\n";
  59. print "Splitting that on tabs gives the following:\n";
  60. print "\n";
  61. @stuff = split(/\t/,$_,10);
  62.  
  63. $args=0;
  64. foreach $foo (@stuff) {
  65.    print "arg[$args] = $foo\n";         
  66.    $args++;
  67. }
  68.  
  69. print "\n";
  70.  
  71.  
  72.  
  73. #---------------------------------
  74.  
  75. /*
  76.  * Copyright (c) 1988 Regents of the University of California.
  77.  * All rights reserved.
  78.  *
  79.  * Redistribution and use in source and binary forms, with or without
  80.  * modification, are permitted provided that the following conditions
  81.  * are met:
  82.  * 1. Redistributions of source code must retain the above copyright
  83.  *    notice, this list of conditions and the following disclaimer.
  84.  * 2. Redistributions in binary form must reproduce the above copyright
  85.  *    notice, this list of conditions and the following disclaimer in the
  86.  *    documentation and/or other materials provided with the distribution.
  87.  * 3. All advertising materials mentioning features or use of this software
  88.  *    must display the following acknowledgement:
  89.  *    This product includes software developed by the University of
  90.  *    California, Berkeley and its contributors.
  91.  * 4. Neither the name of the University nor the names of its contributors
  92.  *    may be used to endorse or promote products derived from this software
  93.  *    without specific prior written permission.
  94.  *
  95.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  96.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  97.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  98.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  99.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  100.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  101.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  102.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  103.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  104.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  105.  * SUCH DAMAGE.
  106.  */
  107.  
  108. #if defined(LIBC_SCCS) && !defined(lint)
  109. static char sccsid[] = "@(#)strtok.c    5.8 (Berkeley) 2/24/91";
  110. #endif /* LIBC_SCCS and not lint */
  111.  
  112. #include <stddef.h>
  113. #include <string.h>
  114.  
  115. char *
  116. strtok(s, delim)
  117.     register char *s;
  118.     register const char *delim;
  119. {
  120.     register char *spanp;
  121.     register int c, sc;
  122.     char *tok;
  123.     static char *last;
  124.  
  125.  
  126.     if (s == NULL && (s = last) == NULL)
  127.         return (NULL);
  128.  
  129.     /*
  130.      * Skip (span) leading delimiters (s += strspn(s, delim), sort of).
  131.      */
  132. cont:
  133.     c = *s++;
  134.     for (spanp = (char *)delim; (sc = *spanp++) != 0;) {
  135.         if (c == sc)
  136.             goto cont;
  137.     }
  138.  
  139.     if (c == 0) {        /* no non-delimiter characters */
  140.         last = NULL;
  141.         return (NULL);
  142.     }
  143.     tok = s - 1;
  144.  
  145.     /*
  146.      * Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
  147.      * Note that delim must have one NUL; we stop if we see that, too.
  148.      */
  149.     for (;;) {
  150.         c = *s++;
  151.         spanp = (char *)delim;
  152.         do {
  153.             if ((sc = *spanp++) == c) {
  154.                 if (c == 0)
  155.                     s = NULL;
  156.                 else
  157.                     s[-1] = 0;
  158.                 last = s;
  159.                 return (tok);
  160.             }
  161.         } while (sc != 0);
  162.     }
  163.     /* NOTREACHED */
  164. }
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.